<?php
session_start(); 
if(!isset($_SESSION['userName'])){
header( 'location:index.php' ); 
}
	include("../../conf/connect.php");
	$user_id = $_SESSION['user_id'];
	$hhid= $_GET['hhid'];
	$bid= $_GET['bid'];
	
	if ($bid==3){
		$_SESSION['usrHHid']=$hhid;
		header( 'location: ../rel_detail.php' );
	}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title></title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link rel="stylesheet" type="text/css" href="../../style.css" media="screen" />
	<link rel="shortcut icon" href="../images/favicon.ico" />
</head>
<body class="iub_back">
	<form method="post" action="update_operation.php?qus=upd">
	<table align="center" class="table_border">
			<tr>
					<td class="header"><b class="htext">IUB Survey :: </b><br /><hr /> </td>
			</tr>
			<?php
			if($bid == '2'){
			$sql ="SELECT * FROM raw_data where user_id='$user_id' and hid='$hhid' and rid='$bid'";
			$result=mysql_query( $sql);
			?>
			<tr>
					<td> Member : </td>
			</tr>
			<tr>
					<td>
						<select name="memid">
						<?php
							
							$data;
							while($row = mysql_fetch_array($result)){
						?>
								<option value="<?php echo $row['id'];?>"><?php echo $row['q1'];?></option>
						<?php
							}
						?>						
						</select>
					</td>
			</tr>
			<?php
			}
			?>
			<tr>
					<td> Field : </td>
			</tr>
			<tr>
					<td><input type="hidden" name="bid" value="<?php echo $bid;?> " />
						<select name="qusNo">
						
								<option value="q1"><?php if($bid !=2){?>Rspndt<?php }else{ ?>Name<?php }?></option>
								<option value="q2">Age</option>
								<option value="q3">Sex</option>
								<option value="q4">Mrtl Stts</option>
								<option value="q5">Rel w HH</option>
								<option value="q6">Schlng</option>
								<option value="q7">Occptn</option>
								<!--<option value="q8">Schl Type</option>
								<option value="q9">Father</option>
								<option value="q7">Mother</option>
								<option value="q11">Spouse</option>
								<option value="q12">Spouse Sch Type</option>
								<option value="q13">Spouse Schlng Yr</option>
								<option value="q14">Spouse Occptn</option>!-->
						</select>
					</td>
			</tr>
			<tr>
					<td align="right" valign="bottom"><input type="submit" value="Update" class="input-box" /> &nbsp;&nbsp;<a href="../index2.php" class="input-box"> Home &nbsp;&nbsp; </a></td>
			</tr>
			<tr>
					<td> <i>Answer(s)</i> : <input type="hidden" name="hhhid" value="<?php echo $hhid;?>" /></td>
			</tr>
			 		
			<?php
				$sql ="SELECT * FROM raw_data where user_id='$user_id' and hid='$hhid'";
				$result=mysql_query( $sql);
				$sr='';
				$i=1;
				$row = mysql_fetch_array($result);
				//print_r($row);
				//exit;
					for($i=1;$i<15;$i++){
						//echo $i;
						$s='q'.$i;
						$sr=$row["$s"];
						
					
			?>
			<?php
						if($s=='q1'){
			?>
			<tr>
					<td>	<?php echo "Name : ".$sr;?></td>
					
			</tr>
			<?php	 	}
			
						else if($s=='q2'){
			?>
			<tr>
					<td>	<?php echo "Age : ".$sr;?></td>
					
			</tr>
			<?php	 	}
						
						else if($s=='q6'){//($s=='q9')||($s=='q10')||($s=='q11')||($s=='q13')){?>
			<tr>
					<td>	<?php echo "Yr of Schlng : ".$sr;?></td>
					
			</tr>
			<?php	 	}
			
						else if($s=='q9'){//($s=='q10')||($s=='q11')||($s=='q13')){?>
			<tr>
					<td>	<?php echo "Father : ".$sr;?></td>
					
			</tr>
			<?php	 	}
			
						else if($s=='q10'){//($i==5)||($s=='q6')||($s=='q9')||($s=='q10')||($s=='q11')||($s=='q13')){?>
			<tr>
					<td>	<?php echo "Mother : ".$sr;?></td>
					
			</tr>
			<?php	 	}
			
						/*else if($s=='q11'){
			?>
			<tr>
					<td>	<?php echo "Spouse : ".$sr;?></td>
					
			</tr>
			<?php	 	}*/
			
						else{
			?>
			
			<tr>
					<td>
						<?php 	
								$data='q'.$i;
						
								$hello="SELECT * FROM retreive_data where qus='$data' and hoption='$sr'";
								$end=mysql_query($hello);
								while($value=mysql_fetch_array($end)){
										if($s=='q3'){
											echo "Sex : ";
											echo $value['value'];
										}
										else if($s=='q4'){
											echo "Marital Status: ";
											echo $value['value'];
										}
										else if($s=='q5'){
											echo "Reltn with HHH: ";
											echo $value['value'];
										}
										else if($s=='q7'){
											echo "Occptn: ";
											echo $value['value'];
										}
										/*else if($s=='q8'){
											echo "Sch Type : ";
											echo $value['value'];
										}
										else if($s=='q12'){
											echo "Spouse Sch Type : ";
											echo $value['value'];
										}
										else if($s=='q13'){
											echo "Spouse Schln Yrs: ";
											echo $value['value'];
										}
										else if($s=='q14'){
											echo "Spouse Occptn: ";
											echo $value['value'];
										}*/							 
								}
								//$data=$row['hc01_1'];
								 
						?>
					</td>	
			</tr>
						
			<?php		}
				}	
						
								
				//}			
			?>
			?>
						
		</table>
		</form>
</body>
</html>